package constants

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将常量值压入操作数栈

// 将引用类型的null值压栈
type ACONST_NULL struct{ base.NoOperandsInstruction }
// 将double类型的0.0入栈
type DCONST_0 struct{ base.NoOperandsInstruction }
// 将double类型的1.0入栈
type DCONST_1 struct{ base.NoOperandsInstruction }
// 将float类型的0.0入栈
type FCONST_0 struct{ base.NoOperandsInstruction }
// 将float类型的1.0入栈
type FCONST_1 struct{ base.NoOperandsInstruction }
// 将float类型的2.0入栈
type FCONST_2 struct{ base.NoOperandsInstruction }
// 将int类型的-1入栈
type ICONST_M1 struct{ base.NoOperandsInstruction }
type ICONST_0 struct{ base.NoOperandsInstruction }
type ICONST_1 struct{ base.NoOperandsInstruction }
type ICONST_2 struct{ base.NoOperandsInstruction }
type ICONST_3 struct{ base.NoOperandsInstruction }
type ICONST_4 struct{ base.NoOperandsInstruction }
type ICONST_5 struct{ base.NoOperandsInstruction }
// 将long类型的0入栈
type LCONST_0 struct{ base.NoOperandsInstruction }
type LCONST_1 struct{ base.NoOperandsInstruction }

func (self *ACONST_NULL) Execute(frame *runtime_area.Frame) { frame.OperandStack().PushRef(nil) }
func (self *DCONST_0) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushDouble(0.0) }
func (self *DCONST_1) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushDouble(1.0) }
func (self *FCONST_0) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushFloat(0.0) }
func (self *FCONST_1) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushFloat(1.0) }
func (self *FCONST_2) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushFloat(2.0) }
func (self *ICONST_M1) Execute(frame *runtime_area.Frame)   { frame.OperandStack().PushInt(-1) }
func (self *ICONST_0) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(0) }
func (self *ICONST_1) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(1) }
func (self *ICONST_2) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(2) }
func (self *ICONST_3) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(3) }
func (self *ICONST_4) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(4) }
func (self *ICONST_5) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushInt(5) }
func (self *LCONST_0) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushLong(0) }
func (self *LCONST_1) Execute(frame *runtime_area.Frame)    { frame.OperandStack().PushLong(1) }
